package org.example.rxJava;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import rx.Observable;

import java.util.concurrent.TimeUnit;

@Slf4j
public class OtherOperatorDemo {

    @Test
    public void takeDemo() throws InterruptedException {
        // 在流上只获取10个元素
        Observable.interval(1, TimeUnit.SECONDS)
                .take(20)
                .map(i->i*2)
                .subscribe(s -> {
                    log.info(String.valueOf(s));
                });
        Thread.sleep(Integer.MAX_VALUE);
    }
}
